﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace HttpListenerApplication
{
    public class DefaultDevices : IDevices
    {
        public string mainBoardId()
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_baseboard");
            string serialNumber = null;
            foreach (ManagementObject mgt in searcher.Get())
            {
                serialNumber = mgt["SerialNumber"].ToString();
            }
            return serialNumber;
        }

        public string systemInstallDay()
        {
            System.Management.ObjectQuery MyQuery = new System.Management.ObjectQuery("SELECT * FROM Win32_OperatingSystem");
            System.Management.ManagementScope MyScope = new System.Management.ManagementScope();
            ManagementObjectSearcher MySearch = new ManagementObjectSearcher(MyScope, MyQuery);
            ManagementObjectCollection MyCollection = MySearch.Get();
            string StrInfo = "";
            foreach (ManagementObject MyObject in MyCollection)
            {
                StrInfo = MyObject.GetText(TextFormat.Mof);
            }
            string InstallDate = StrInfo.Substring(StrInfo.LastIndexOf("InstallDate") + 15, 14);
            Console.Write("系统安装时间：" + InstallDate);
            return InstallDate;
        }
    }
}
